package com.example.mydy.model;

import com.google.gson.annotations.SerializedName;
import java.util.HashMap;
import java.util.Map;

public class UserInfo {
    private int id;
    private String username;
    private String userType;
    private String password;
    
    @SerializedName("userNickname")
    private String nickname;
    
    private String email;
    private String phone;
    private String balance;
    private String level;
    private int points;
    private String status;
    private String createdAt;
    private String inviteCode;
    private String inviter; // 邀请人用户名
    private boolean isAdmin;
    private String avatarUrl;
    
    // 添加额外的属性存储
    private Map<String, String> extraData;
    
    public UserInfo() {
        // 空构造函数
        extraData = new HashMap<>();
    }
    
    public UserInfo(int id, String username, String nickname, String phone, double balance, int points, String level, String status, String createdAt) {
        this.id = id;
        this.username = username;
        this.nickname = nickname;
        this.phone = phone;
        this.balance = String.valueOf(balance);
        this.points = points;
        this.level = level;
        this.status = status;
        this.createdAt = createdAt;
        extraData = new HashMap<>();
    }
    
    // 存储额外的属性
    public void putExtra(String key, String value) {
        if (extraData == null) {
            extraData = new HashMap<>();
        }
        extraData.put(key, value);
    }
    
    // 获取额外的属性
    public String getExtra(String key) {
        if (extraData == null) {
            return null;
        }
        return extraData.get(key);
    }
    
    // 获取整个额外数据Map
    public Map<String, String> getAllExtraData() {
        return extraData;
    }
    
    public int getId() {
        return id;
    }
    
    public void setId(int id) {
        this.id = id;
    }
    
    public String getUsername() {
        return username;
    }
    
    public void setUsername(String username) {
        this.username = username;
    }
    
    public String getUserType() {
        return userType;
    }
    
    public void setUserType(String userType) {
        this.userType = userType;
    }
    
    public String getNickname() {
        return nickname;
    }
    
    public void setNickname(String nickname) {
        this.nickname = nickname;
    }
    
    public String getEmail() {
        return email;
    }
    
    public void setEmail(String email) {
        this.email = email;
    }
    
    public String getPhone() {
        return phone;
    }
    
    public void setPhone(String phone) {
        this.phone = phone;
    }
    
    public String getBalance() {
        return balance;
    }
    
    public void setBalance(String balance) {
        this.balance = balance;
    }
    
    public void setBalance(double balance) {
        this.balance = String.valueOf(balance);
    }
    
    public String getLevel() {
        return level;
    }
    
    public void setLevel(String level) {
        this.level = level;
    }
    
    public int getPoints() {
        return points;
    }
    
    public void setPoints(int points) {
        this.points = points;
    }
    
    public String getStatus() {
        return status;
    }
    
    public void setStatus(String status) {
        this.status = status;
    }
    
    public String getCreatedAt() {
        return createdAt;
    }
    
    public void setCreatedAt(String createdAt) {
        this.createdAt = createdAt;
    }
    
    public String getInviteCode() {
        return inviteCode;
    }
    
    public void setInviteCode(String inviteCode) {
        this.inviteCode = inviteCode;
    }
    
    public String getInviter() {
        return inviter;
    }
    
    public void setInviter(String inviter) {
        this.inviter = inviter;
    }
    
    public boolean isAdmin() {
        return isAdmin;
    }
    
    public void setAdmin(boolean admin) {
        isAdmin = admin;
    }
    
    public String getPassword() {
        return password;
    }
    
    public void setPassword(String password) {
        this.password = password;
    }
    
    public String getAvatarUrl() {
        return avatarUrl;
    }
    
    public void setAvatarUrl(String avatarUrl) {
        this.avatarUrl = avatarUrl;
    }
    
    @Override
    public String toString() {
        return "UserInfo{" +
                "id=" + id +
                ", username='" + username + '\'' +
                ", userType='" + userType + '\'' +
                ", nickname='" + nickname + '\'' +
                ", email='" + email + '\'' +
                ", phone='" + phone + '\'' +
                ", balance='" + balance + '\'' +
                ", level='" + level + '\'' +
                ", points=" + points +
                ", status='" + status + '\'' +
                ", createdAt='" + createdAt + '\'' +
                ", inviteCode='" + inviteCode + '\'' +
                ", inviter='" + inviter + '\'' +
                ", isAdmin=" + isAdmin +
                ", avatarUrl='" + avatarUrl + '\'' +
                '}';
    }
}